#ifndef PBVP_GEOMETRY_FLOW_H
#define PBVP_GEOMETRY_FLOW_H
/************************************************************************/
/* Implement a geometric flow under a driving function                  */
/* The function describing the surface is assumed to be a SDF, or should
   be initialized to a SDF.												*/
/* The geometry flow algorithm is based on Xuguo's paper and modified 
   from the HLevelset code.												*/
/************************************************************************/
#include "../data/geometrydata.h"
#include "../data/reg3dvolumedata.h"
#include "../math/Vector3.h"

namespace PBVP {
	class GeometryFlow {
	public:
		/// Constructor
		/** 
		 * @param phi Shape function determines the marching surface as 0 contour phi = 0
		 * @param func Driving function (usually positive in the domain)
		 *
		 * @note The function phi and func are assumed to be in the same domain with same \
		 *       dimensions
		 */
		GeometryFlow(Reg3DVolumeData* phi, Reg3DVolumeData *func);

		/// Destructor
		~GeometryFlow();

		/// 
		/** 
		 * @param maxIteration The maximum number of iterations.
		 */
		void evolve(int maxIterations);

		/// Flow for one iteration
		void flow();

		/// Reinitialize the shape function Phi to a SDF 
		void reinitilization();

	private:
		Reg3DVolumeData* mp_Phi;
		Reg3DVolumeData* mp_Func;
		float *mp_Up;

		double m_dt;
		
		unsigned int nx, ny, nz;
		float dx, dy, dz;

		double m_MaxDepth;
	};
}
#endif